package edu.java.homework.hw03.ipj05;

public class J02 {

    /**
     * @param args
     */
    public static void main(String[] args) {
	int[] arr = { 1, 2, 3, 4, 5, 2, 3, 5, 10, 21, 1, 3, 2, 15 };
	// int[] arr=null;
	System.out.println("isNumberInArray? : " + isNumberInArray(arr, 17));
	
    }

    /**
     * Check if a number is in array
     * 
     * @param array
     * @param number
     * @return boolean
     * @throws IllegalArgumentException
     *             the array must be not null pointed
     */
    public static boolean isNumberInArray(int[] array, int number) {
	if (array == null) {
	    throw new IllegalArgumentException(
		    "The array is null pointed.Incorrect input.");
	}
	for (int index = 0; index < array.length; index++) {
	    if (number == array[index]) {
		return true;
	    }
	}
	return false;

    }

}
